package 多线程和队列.oom;

import java.util.Random;

/**
 * 堆内存溢出
 * // -Xms10M -Xmx10M -XX:+PrintGCDetails -XX:MaxDirectMemorySize=5M
 * Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
 */
public class JavaHeapSpaceDemo {

    public static void main(String[] args) {
        String str = "atguigu";

        while (true) {
            str += str + new Random().nextInt(11111111) + new Random().nextInt(222222222);
            str.intern();
        }

    }
}
